home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
debugnub
/
CirioNubProcs1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
16KB
|
621 lines
/* begincopyright
Copyright (c) 1988-1992 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
/*
* CirioNubProcs1.c
*
* Demers, February 25, 1992 11:46:00 am PST
*/
#include "xr/Errno.h"
#include "xr/Threads.h"
#include "xr/ThreadsBackdoor.h"
#include "xr/IncrementalLoad.h"
#include "xr/CirioNubProtocol.h"
#include "xr/CirioNubMarshall.h"
#include "xr/CirioNubProcs.h"
#include "xr/CirioNubInnerProcs.h"
#include "xr/CirioNubEnvironment.h"
CirioNubRetCode
CirioNubServeWaitSig(argc, args)
int argc;
unsigned *args;
{
bool gotSig;
CirioNubRetCode ans;
if( argc != 1 )
return(cnrc_badArgs);
if( (!cns.cns_gotSig) && (args[0] != 0) )
(void)CirioNubSlaveSleep((unsigned)(args[0]));
if( (gotSig = cns.cns_gotSig) != FALSE )
cns.cns_gotSig = FALSE;
if( (ans = CirioNubPutInt32(gotSig)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutInt32(XR_sysArea->sa_dbStat)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeSetDBStat (argc, args)
int argc;
unsigned *args;
{
XR_DBStat stat;
unsigned timeoutMsec;
unsigned sleepMsec = 100;
unsigned timeoutSoFar;
int i, j;
if( argc != 2 )
return(cnrc_badArgs);
stat = (XR_DBStat)(args[0]);
timeoutMsec = (unsigned)(args[1]);
i = 0;
timeoutSoFar = 0;
for(;;) {
XR_sysArea->sa_dbStat = stat;
if( (i % 5) == 0 ) CirioNubKickDebuggee();
i += 1;
for( j = 0; j < XR_sysArea->sa_numVP; j++ ) {
if( XR_sysArea->sa_vpe[j].vpe_dbStat != stat ) goto Nope;
}
return CirioNubPutInt32(0);
Nope:
if( timeoutSoFar >= timeoutMsec ) return CirioNubPutInt32(-1);
(void)CirioNubSlaveSleep(sleepMsec);
timeoutSoFar += sleepMsec;
}
}
CirioNubRetCode
CirioNubServeGetMaxThreads(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
if( argc != 0 ) return(cnrc_badArgs);
if( (ans = CirioNubPutCard32(XR_maxThreads)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeGetThreads(argc, args)
int argc;
unsigned *args;
{
# define MAX_THREAD_DATA 128
int i, iLow, iHigh, localAns;
CirioNubThreadData dp, dpLim;
XR_Thread t;
CirioNubRetCode ans;
struct CirioNubThreadDataRep data[MAX_THREAD_DATA];
if( argc != 2 ) return(cnrc_badArgs);
iLow = (int)(args[0]);
iHigh = (int)(args[1]);
if( iLow >= 0 ) {
if( iHigh >= XR_maxThreads ) iHigh = XR_maxThreads - 1;
if( iLow > iHigh ) return(cnrc_badArgs);
} else {
iHigh = iLow; /* both < 0, that's okay ... */
}
dp = &(data[0]);
dpLim = &(data[MAX_THREAD_DATA]);
for( i = iLow; i <= iHigh; i++ ) {
if( dp >= dpLim ) return cnrc_space;
localAns = CirioNubInnerGetThread(i, dp);
if( localAns == 0 ) dp++;
}
ans = CirioNubPutBlock32(
&(data[0]),
((unsigned)(dp)) - ((unsigned)(&(data[0])))
);
if( ans != cnrc_ok ) return ans;
return cnrc_ok;
#undef MAX_THREAD_DATA
}
CirioNubRetCode
CirioNubServeGetThreadFromCTRep(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
XR_Thread t;
unsigned gen;
unsigned innerArgs[2];
if( argc != 2 ) return(cnrc_badArgs);
t = (XR_Thread)(args[0]);
gen = (unsigned)(args[1]);
if( (t < XR_sysArea->sa_threadPool) ||
(t >= &(XR_sysArea->sa_threadPool[XR_maxThreads])) )
return(cnrc_badArgs);
if( gen != t->t_gen )
return(cnrc_badArgs);
innerArgs[0] = innerArgs[1] = (unsigned)(-((int)(t->t_index)));
return CirioNubServeGetThreads(2, innerArgs);
}
CirioNubRetCode
CirioNubServePCtoInfo(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
int innerAns;
XR_Pointer argValue;
struct CirioNubPCInfoRep buf;
if( argc != 1 ) return(cnrc_badArgs);
argValue = (XR_Pointer)(args[0]);
innerAns = CirioNubInnerPCtoInfo(argValue, &buf);
if( innerAns != 0 ) return cnrc_badArgs;
Out:
{
if( (ans = CirioNubPutString(buf.procName)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.procSymID)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutString(buf.fileName)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.fileSeqNum)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutString(buf.guessedEmbeddedFileName)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.guessedEmbeddedFileSymID)) != cnrc_ok )
return ans;
}
return cnrc_ok;
}
static bool
CirioNubServeKillWorldInner()
{
(void) CirioNubSlaveSleep(2000);
XR_KillWorld();
_exit(0);
/*NOTREACHED*/
return TRUE;
}
CirioNubRetCode
CirioNubServeKillWorld(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
if( argc != 0 ) return(cnrc_badArgs);
XR_iope->iope_workerProc = CirioNubServeKillWorldInner;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeIssueThreadCommand(argc, args)
int argc;
unsigned *args;
{
XR_Thread t;
int index;
bool setFreeze;
bool freeze;
bool setMsg;
XR_DBMsg msg;
if( argc != 5 ) return(cnrc_badArgs);
index = (int)(args[0]);
setFreeze = (bool)(args[1]);
freeze = (bool)(args[2]);
setMsg = (bool)(args[3]);
msg = (XR_DBMsg)(args[4]);
if( (index < XR_sysArea->sa_numVP)
|| (index >= XR_maxThreads) )
return CirioNubPutInt32(-1);
t = &(XR_sysArea->sa_threadPool[index]);
if( setFreeze ) t->t_dbFreeze = freeze;
if( setMsg ) t->t_dbMsg = msg;
return CirioNubPutInt32(0);
}
CirioNubRetCode
CirioNubServeGetDBStat(argc, args)
int argc;
unsigned *args;
{
XR_Thread examinee;
CirioNubRetCode ans;
int oldStat;
int oldExamineeIndex;
unsigned timeoutMsec;
int newStat;
int newExamineeIndex;
unsigned sleepTime;
if( argc != 3 ) return( cnrc_badArgs );
oldStat = (int)(args[0]);
oldExamineeIndex = (int)(args[1]);
timeoutMsec = (unsigned)(args[2]);
for(;;) {
newStat = XR_sysArea->sa_dbStat;
examinee = XR_sysArea->sa_examinee;
newExamineeIndex = ( (examinee != NIL) ? examinee->t_index : (-1) );
if( timeoutMsec == 0 )
break;
if( (newStat != oldStat) || (newExamineeIndex != oldExamineeIndex) )
break;
sleepTime = ( (timeoutMsec < 250) ? timeoutMsec : 250 );
(void)CirioNubSlaveSleep(sleepTime);
timeoutMsec -= sleepTime;
}
if( (ans = CirioNubPutInt32(newStat)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutInt32(newExamineeIndex)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeGetFileEntry(argc, args)
int argc;
unsigned *args;
{
unsigned desiredSeqNum;
CirioNubRetCode ans;
int innerAns;
struct CirioNubFileEntryRep buf;
if( argc != 1 ) return(cnrc_badArgs);
desiredSeqNum = (unsigned)(args[0]);
innerAns = CirioNubInnerGetFileEntry(desiredSeqNum, &buf);
if( innerAns != 0 ) return cnrc_badArgs;
{
if( (ans = CirioNubPutCard32(buf.seqNum)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.commitPoint)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutString(buf.fileName)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.fOffset)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.fMagic)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.size)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.mTime)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.sMagic)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(((unsigned)(buf.stamp))))
!= cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.stampSize)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(((unsigned)(buf.readerData)))) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.readerDataSize)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.patchReloc)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.patchSize)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.textReloc)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.textSize)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.dataReloc)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.dataSize)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.bssReloc)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.bssSize)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.commonReloc)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf.commonSize)) != cnrc_ok )
return ans;
}
return cnrc_ok;
}
static CirioNubRetCode
CirioNubPutSymEntryResult(errCode, buf)
int errCode;
CirioNubSymEntry buf;
{
CirioNubRetCode ans;
if( (buf == NIL) && (errCode == 0) )
errCode = (-1);
if( (ans = CirioNubPutInt32(errCode)) != cnrc_ok )
return ans;
if( errCode != 0 )
return cnrc_ok;
if( (ans = CirioNubPutCard32(buf->symID)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutString(buf->name)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf->type)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf->value)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf->size)) != cnrc_ok )
return ans;
if( (ans = CirioNubPutCard32(buf->fileSeqNum)) != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeGetMatchingSymEntryByName(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
unsigned symID;
char *pattern;
bool caseSensitive;
unsigned wantedTypes;
unsigned ignoredClasses;
int numToSkip;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 6 ) return( cnrc_badArgs );
symID = (unsigned)(args[0]);
pattern = (char *)(args[1]);
caseSensitive = (bool)(args[2]);
wantedTypes = (unsigned)(args[3]);
ignoredClasses = (unsigned)(args[4]);
numToSkip = (int)(args[5]);
innerAns = CirioNubInnerGetMatchingSymEntryByName (
symID, pattern, caseSensitive, wantedTypes,
ignoredClasses, numToSkip, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeGetMatchingSymEntryByValue(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
unsigned symID;
unsigned val;
unsigned wantedTypes;
unsigned ignoredClasses;
int numToSkip;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 5 ) return( cnrc_badArgs );
symID = (unsigned)(args[0]);
val = (unsigned)(args[1]);
wantedTypes = (unsigned)(args[2]);
ignoredClasses = (unsigned)(args[3]);
numToSkip = (int)(args[4]);
innerAns = CirioNubInnerGetMatchingSymEntryByValue (
symID, val, wantedTypes, ignoredClasses, numToSkip, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
/* OBSOLETE: */
CirioNubRetCode
CirioNubServeLookupSymEntryByName(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
char *sym;
bool caseSensitive;
bool externOnly;
int numToSkip;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 4 ) return( cnrc_badArgs );
sym = (char *)(args[0]);
caseSensitive = (bool)(args[1]);
externOnly = (bool)(args[2]);
numToSkip = (int)(args[3]);
innerAns = CirioNubInnerGetMatchingSymEntryByName (
0, sym, caseSensitive, WANT_ALL_TYPES,
(externOnly ? IGNORE_INTERNAL : IGNORE_NONE),
numToSkip, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeSkipSymEntryByName(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
unsigned symID;
bool caseSensitive;
bool externOnly;
int numToSkip;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 4 ) return( cnrc_badArgs );
symID = (unsigned)(args[0]);
caseSensitive = (bool)(args[1]);
externOnly = (bool)(args[2]);
numToSkip = (int)(args[3]);
innerAns = CirioNubInnerGetMatchingSymEntryByName(
symID, NIL, caseSensitive, WANT_ALL_TYPES,
(externOnly ? IGNORE_INTERNAL : IGNORE_NONE),
numToSkip, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeLookupSymEntryByValue(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
unsigned val;
int numToSkip;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 2 ) return( cnrc_badArgs );
val = (unsigned)(args[0]);
numToSkip = (int)(args[1]);
innerAns = CirioNubInnerGetMatchingSymEntryByValue (
NIL, val, WANT_ALL_TYPES, IGNORE_NONE, numToSkip, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeSkipSymEntryByValue(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
unsigned symID;
int numToSkip;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 2 ) return( cnrc_badArgs );
symID = (unsigned)(args[0]);
numToSkip = (int)(args[1]);
innerAns = CirioNubInnerGetMatchingSymEntryByValue(
symID, 0, WANT_ALL_TYPES, IGNORE_NONE, numToSkip, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeLookupSymEntryByID(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
unsigned symID;
int innerAns;
struct CirioNubSymEntryRep buf;
if( argc != 1 ) return( cnrc_badArgs );
symID = (unsigned)(args[0]);
innerAns = CirioNubInnerGetMatchingSymEntryByValue(
symID, 0, WANT_ALL_TYPES, IGNORE_NONE, 0, &buf
);
ans = CirioNubPutSymEntryResult( ((innerAns == 0) ? 0 : (-1)), &buf );
if( ans != cnrc_ok )
return ans;
return cnrc_ok;
}
CirioNubRetCode
CirioNubServeGetInstrSetAndOpSys(argc, args)
int argc;
unsigned *args;
{
CirioNubRetCode ans;
struct CirioNubInstrSetAndOpSysRep buf;
int innerAns;
if( argc != 0 ) return cnrc_badArgs;
innerAns = CirioNubInnerGetInstrSetAndOpSys(&buf);
if( innerAns != 0 ) return cnrc_badArgs;
if( (ans = CirioNubPutString(buf.instrSet)) != cnrc_ok ) return ans;
if( (ans = CirioNubPutString(buf.opSys)) != cnrc_ok ) return ans;
return cnrc_ok;
}